package com.jinzhi.common.utils;

import java.util.HashMap;
import java.util.Map;

public class ParamsUtils {
    private static final String SEPARTOR_1 = "@";
    private static final String SEPARTOR_2 = "#";
    private static final String SEPARTOR_3 = "~";

    public static Map changeParams(String params){
        Map map = new HashMap();
        //将params字符串按规格转为Map
        if (params.indexOf(SEPARTOR_2) != -1){
            String[] strings = params.split(SEPARTOR_2);
            for (int i = 0; i < strings.length; i++){
                if (strings[i].indexOf(SEPARTOR_3) != -1){
                    String[] split = strings[i].split(SEPARTOR_3);
                    map.put(split[0],split[1]);
                }
            }
        }
        return map;
    }

    public static String changeUrl(String url){
        url = url.replace(SEPARTOR_1,"?");
        url = url.replace(SEPARTOR_2,"&");
        url = url.replace(SEPARTOR_3,"=");
        return url;
    }

}
